//
//  CommunityDetailsViewController.m
//  17DianYing
//
//  Created by apple on 15/9/26.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "CommunityDetailsViewController.h"
#import "MBProgressHUD.h"



@interface CommunityDetailsViewController ()<UIWebViewDelegate,MBProgressHUDDelegate>

{
    MBProgressHUD *HUD;
    long long expectedLength;
    long long currentLength;
    
}


@property (weak, nonatomic) IBOutlet UIWebView *tableWeb;
@end

@implementation CommunityDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    NSString *filmStr = [@"http://17dianying.cn/v2/weixin/index.html#/film/" stringByAppendingString:self.filmId];
    
    NSURL *url = [NSURL URLWithString:filmStr];
    
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [self.tableWeb loadRequest:req];
    self.tableWeb.delegate = self;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];
    
    HUD.dimBackground = YES;
    
    
    HUD.delegate = self;
    
    
    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUD hide:YES];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"加载网页失败:%@",error.localizedDescription);
}


- (void)myTask {
    // Do something usefull in here instead of sleeping ...
    sleep(6);
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
